package com.labichaoka.chaoka.ui.fetch;

import com.labichaoka.chaoka.entity.BaseResponse;
import com.labichaoka.chaoka.entity.FetchMoneyRequest;
import com.labichaoka.chaoka.entity.FetchMoneyResponse;
import com.labichaoka.chaoka.entity.GetWithdrawInfo;
import com.labichaoka.chaoka.entity.IsOpenAcountRequest;
import com.labichaoka.chaoka.entity.IsOpenAcountResponse;
import com.labichaoka.chaoka.entity.LimitStatusResponse;

/**
 * Created by ruan on 2018/8/13.
 */

public class FetchMoneyPresenterImpl implements FetchMoneyPresenter,FetchMoneyInteractor.OnFinishedListener {
    private FetchMoneyInteractor interactor;
    private FetchMoneyView view;

    public FetchMoneyPresenterImpl(FetchMoneyInteractor interactor, FetchMoneyView view) {
        this.interactor = interactor;
        this.view = view;
    }

    @Override
    public void calculate() {
        if (view!=null){
            view.showProgress();
        }
        interactor.getQuotaInfo(this);
    }

    @Override
    public void commit(FetchMoneyRequest request) {
        if (view!=null){
            view.showProgress();
        }
        interactor.commit(request,this);
    }

    @Override
    public void isOpenAcount(IsOpenAcountRequest request) {
        if (view!=null){
            view.showProgress();
        }
        interactor.isOpenAcount(request,this);
    }

    @Override
    public void onDestroy() {
        view=null;
    }

    @Override
    public void onSuccessed(LimitStatusResponse response) {
        view.hideProgress();
        view.setData(response);
    }

    @Override
    public void onFailed() {
        view.hideProgress();
    }

    @Override
    public void onCommitSuccessed(FetchMoneyResponse response) {
        view.hideProgress();
        view.commit(response);
    }

    @Override
    public void onCommitFailed() {
        view.hideProgress();
    }

    @Override
    public void onIsOpenAcountSucc(IsOpenAcountResponse response) {
        view.hideProgress();
        view.isOpenAcountCallback(response);
    }

    @Override
    public void onIsOpenAcountFailed() {
        view.hideProgress();
    }


}
